
const defaultState = {
    // 路径
    path: '',

    // 是否为目录
    isDir: false,

    // 是否显示
    isOpen: false
};

/**
 * 显示提示框
 * @type {String}
 */
export const SHOW_CONFIRM_DELETE_DIALOG = 'SHOW_CONFIRM_DELETE_DIALOG';

/**
 * 关闭提示框
 * @type {String}
 */
export const HIDE_CONFIRM_DELETE_DIALOG = 'HIDE_CONFIRM_DELETE_DIALOG';

/**
 * 确认删除提示框 Reducer
 * @param {Object} state
 * @param {Object} action
 */
export default function confirmDeleteDialogReducer(state = defaultState, action) {
    switch (action.type) {
        case SHOW_CONFIRM_DELETE_DIALOG:
            return {
                ...state,
                path: action.payload.path,
                isDir: action.payload.isDir,
                isOpen: true
            };
        case HIDE_CONFIRM_DELETE_DIALOG:
            return {
                ...state,
                isOpen: false
            };
        default:
            return state;
    }
}